import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Log {
    public void log(String s) {
        PrintStream printStream = null;
        try {
            printStream = new PrintStream(new FileOutputStream("log.txt",true));
            System.setOut(printStream);
            Date time = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
            String strTime = sdf.format(time);
            printStream.println(strTime + "  " + s);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            if (printStream != null) {
                printStream.close();
            }
        }


    }

}
